import { handleActions } from 'redux-actions'
import { USERINFO, GLOBALDATA,CITY  } from '../types/counter'

export default handleActions({
  // 用户信息
  [USERINFO] (state, action) {
    return {
      ...state,
      userInfo: state.userInfo || action.payload
    }
  },
  // 全局数据
  [GLOBALDATA](state, action) {
    return {
      ...state,
      globalData: action.payload
    }
  },
  // 全局城市
  [CITY](state, action) {
    return {
      ...state,
      city: action.payload
    }
  },
}, {
  userInfo: null,
  globalData: null,
  city:{}
})

//数据的类型必须一一对应 否则 dispatch 不成功